<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="./vue.global.js"></script>
  <title>Document</title>
</head>
<body>
  <div id="root">
    <aa></aa>
    <bb></bb>
  </div>
  <script>
    const { createApp, computed, provide, ref, inject, onMounted } = window.Vue

    const AA = {
      template: `
        <div>{{title}}</div>
      `,

      setup(props) {
        let title = inject('title')
        
        return {
          title
        }
      }
    }
    const BB = {
      template: `
        <div>B</div>
      `
    }
    
    const app = createApp({
      components: {
        aa: AA,
        bb: BB
      },

      setup(props) {
        const title = ref('hello')

        provide('title', title)

        onMounted(() => {
          setTimeout(() => {
            title.value = 'world'
          }, 2000)
        })
      }
    })

    let vm = app.mount('#root')
  </script>
</body>
</html>